﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ProductosGestion.aspx.cs" Inherits="Parafarmacia.ProductosGestion" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
           
            <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource1" EmptyDataText="There are no data records to display.">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                    <asp:BoundField DataField="Id" HeaderText="Id" ReadOnly="True" SortExpression="Id" />
                    <asp:BoundField DataField="Tipo" HeaderText="Tipo" SortExpression="Tipo" />
                    <asp:BoundField DataField="NombreProducto" HeaderText="NombreProducto" SortExpression="NombreProducto" />
                    <asp:BoundField DataField="Descripcion" HeaderText="Descripcion" SortExpression="Descripcion" />
                    <asp:BoundField DataField="Detalle" HeaderText="Detalle" SortExpression="Detalle" />
                    <asp:BoundField DataField="Precio" HeaderText="Precio" SortExpression="Precio" />
                    <asp:BoundField DataField="IVA" HeaderText="IVA" SortExpression="IVA" />
                    <asp:BoundField DataField="IdMarca" HeaderText="IdMarca" SortExpression="IdMarca" />
                    <asp:BoundField DataField="IdCategoria" HeaderText="IdCategoria" SortExpression="IdCategoria" />
                    <asp:BoundField DataField="Descuento" HeaderText="Descuento" SortExpression="Descuento" />
                    <asp:CheckBoxField DataField="Oferta" HeaderText="Oferta" SortExpression="Oferta" />
                    <asp:BoundField DataField="Stock" HeaderText="Stock" SortExpression="Stock" />
                    <asp:BoundField DataField="imageUrl" HeaderText="imageUrl" SortExpression="imageUrl" />
                    <asp:ButtonField CommandName="imagesCommand" Text="Imágenes" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:context %>" DeleteCommand="DELETE FROM [tblProducto] WHERE [Id] = @Id" InsertCommand="INSERT INTO [tblProducto] ([Tipo], [NombreProducto], [Descripcion], [Detalle], [Precio], [IVA], [IdMarca], [IdCategoria], [Descuento], [Oferta], [Stock], [imageUrl]) VALUES (@Tipo, @NombreProducto, @Descripcion, @Detalle, @Precio, @IVA, @IdMarca, @IdCategoria, @Descuento, @Oferta, @Stock, @imageUrl)" ProviderName="<%$ ConnectionStrings:context.ProviderName %>" SelectCommand="SELECT [Id], [Tipo], [NombreProducto], [Descripcion], [Detalle], [Precio], [IVA], [IdMarca], [IdCategoria], [Descuento], [Oferta], [Stock], [imageUrl], [tblCategoria_Id], [tblMarca_Id] FROM [tblProducto]" UpdateCommand="UPDATE [tblProducto] SET [Tipo] = @Tipo, [NombreProducto] = @NombreProducto, [Descripcion] = @Descripcion, [Detalle] = @Detalle, [Precio] = @Precio, [IVA] = @IVA, [IdMarca] = @IdMarca, [IdCategoria] = @IdCategoria, [Descuento] = @Descuento, [Oferta] = @Oferta, [Stock] = @Stock, [imageUrl] = @imageUrl WHERE [Id] = @Id">
                <DeleteParameters>
                    <asp:Parameter Name="Id" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="Tipo" Type="String" />
                    <asp:Parameter Name="NombreProducto" Type="String" />
                    <asp:Parameter Name="Descripcion" Type="String" />
                    <asp:Parameter Name="Detalle" Type="String" />
                    <asp:Parameter Name="Precio" Type="Decimal" />
                    <asp:Parameter Name="IVA" Type="Decimal" />
                    <asp:Parameter Name="IdMarca" Type="Int32" />
                    <asp:Parameter Name="IdCategoria" Type="Int32" />
                    <asp:Parameter Name="Descuento" Type="Decimal" />
                    <asp:Parameter Name="Oferta" Type="Boolean" />
                    <asp:Parameter Name="Stock" Type="Int32" />
                    <asp:Parameter Name="imageUrl" Type="String" />
                </InsertParameters>
                <UpdateParameters>
                    <asp:Parameter Name="Tipo" Type="String" />
                    <asp:Parameter Name="NombreProducto" Type="String" />
                    <asp:Parameter Name="Descripcion" Type="String" />
                    <asp:Parameter Name="Detalle" Type="String" />
                    <asp:Parameter Name="Precio" Type="Decimal" />
                    <asp:Parameter Name="IVA" Type="Decimal" />
                    <asp:Parameter Name="IdMarca" Type="Int32" />
                    <asp:Parameter Name="IdCategoria" Type="Int32" />
                    <asp:Parameter Name="Descuento" Type="Decimal" />
                    <asp:Parameter Name="Oferta" Type="Boolean" />
                    <asp:Parameter Name="Stock" Type="Int32" />
                    <asp:Parameter Name="imageUrl" Type="String" />
                    <asp:Parameter Name="Id" Type="Int32" />
                </UpdateParameters>
            </asp:SqlDataSource>

            <asp:Table ID="TableContenidoEditar" runat="server" HorizontalAlign="Center" Width="100%" Caption="Editar:">
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Nombre producto:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtNombreProducto" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                   Detalle:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtDetalle" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Descripción:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtDescripcion" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Tipo:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtTipo" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Precio:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtPrecio" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Descuento:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtDescuento" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Oferta:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:CheckBox ID="chckOferta" runat="server" Width="60%"></asp:CheckBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Stock:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtStock" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Marca:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtMarca" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Categoria:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtCategoria" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>
                 <asp:TableRow>
                    <asp:TableCell Width="40%">
                    Imagen:
                    </asp:TableCell>
                    <asp:TableCell Width="60%">
                        <asp:TextBox ID="txtImagenUrl" runat="server" Width="60%"></asp:TextBox>
                    </asp:TableCell>
                </asp:TableRow>

            </asp:Table>
            <asp:Button ID="butActualizar" runat="server" Text="Actualizar" OnClick="butActualizar_Click" />
        </div>

    </form>
</body>
</html>
